package com.xbongbong.sys.model.impl;

import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.sys.domain.dao.PriceSetDao;
import com.xbongbong.sys.domain.entity.ConditionEntity;
import com.xbongbong.sys.domain.entity.PriceSetEntity;
import com.xbongbong.sys.model.PriceSetModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

;

/**
 * @author bomfish
 */
@Service("priceSetModel")
public class PriceSetModelImpl implements PriceSetModel {
    @Resource
    private PriceSetDao priceSetDao;

    @Override
    public Integer insert(PriceSetEntity entity) {
        return priceSetDao.insert(entity);
    }

    @Override
    public void insertBatch(List<PriceSetEntity> list) {
        priceSetDao.insertBatch(list);
    }

    @Override
    public List<PriceSetEntity> findEntitys(Map<String, Object> param) {
        return priceSetDao.findEntities(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return priceSetDao.getEntitiesCount(param);
    }

    @Override
    public List<PriceSetEntity> findEntitysWithoutSub(Map<String, Object> param) {
        return priceSetDao.findEntities(param);
    }

    @Override
    public Integer update(PriceSetEntity entity) {
        long now = DateTimeUtil.getInt();
        entity.setUpdateTime(now);
        return priceSetDao.update(entity);
    }

    @Override
    public PriceSetEntity getByKey(Long key, String corpid) {
        return priceSetDao.getByKey(key, corpid);
    }

    @Override
    public List<PriceSetEntity> getAllPrices(String corpid) {
        return priceSetDao.getAllPrices(corpid);
    }

    @Override
    public void deleteByKey(Long dataId, String corpid) {
        priceSetDao.deleteByKey(dataId, corpid);
    }

    @Override
    public void updateBatch(List<PriceSetEntity> list, String corpid) {
        priceSetDao.updateBatch(list, corpid);
    }

    @Override
    public Integer getMaxPriority(String corpid) {
        return priceSetDao.getMaxPriority(corpid);
    }

    @Override
    public void updateBatchPriority(String corpid, Integer priority) {
        priceSetDao.updateBatchPriority(corpid, priority);
    }

    @Override
    public List<PriceSetEntity> getPricesByConditions(Map<String, Object> param, List<ConditionEntity> priceConditions) {
        return priceSetDao.getPricesByConditions(param, priceConditions);
    }

    @Override
    public PriceSetEntity getByName(String name, String corpid) {
        return priceSetDao.getByName(name, corpid);
    }

    @Override
    public void closePriceManage(String corpid) {
        priceSetDao.closePriceManage(corpid);
    }

}
